/*
 * Graph.h
 *
 *  Created on: 15/09/2009
 *      Author: mario
 */

#ifndef GRAPH_H_
#define GRAPH_H_
#define null 0
#define DISTANCE_WEIGHT_MODE 0
#define TIME_WEIGHT_MODE 1
#include "List.h"
#include "Vertex.h"
#include "VertexNode.h"
#include "Constants.h"


class Graph {
private:
	int vertexQty;
	List* vertexList;
	bool validateEdge(string idFrom, string idTo);
	int weightMode;

public:
	Graph();
	virtual ~Graph();

	int createVertex(string id, float x, float y);

	int createEdge(string id, string idFrom, string idTo, float length, float maxVelocity, string wayType, string wayName, int initAddress, int lastAddress);

	Vertex* getVertex(string id) const;

	Edge* getEdge(string id) const;

	//Getters & Setters
	int getVertexQty() const;

	void setVertexQty(int vertexQty);

	List* getVertexList() const;

	void setVertexList(List* vertexList);
	
	/**
	 * Gets the vertex located in the specified (x,y) position
	 */
	Vertex* getPosition(float posX, float posY);
	/**
	 * Gets the vertex list's index of a vertex
	 */
	int getIndexOfVertex(Vertex* vertex);

	/**
	 * Returns the corresponding weight of the edge
	 */
	float getEdgeWeight(Edge* edge);

	void setDistanceWeightMode();

	void setTimeWeightMode();

	/**
	 * Returns a list of edges with the same name
	 */
	List* getEdgesListByName(string name) const;

	/**
	 * Returns a list of edges 
	 */
	List* getAllEdgesToVertex(string vertexID) const;

	/**
	 * Delete a Edge from the graph
	 */
	void deleteEdge(string edgeID);

};

#endif /* GRAPH_H_ */
